package base;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

public class GenHtml extends Thread {

	public void run() {
		String path = "./html/";

		while (true) {

			FileWriter fw;
			try {
				fw = new FileWriter(path + "essai.html");
			Random rand = new Random();
			int nombre;
			Calendar cal = Calendar.getInstance() ;
			SimpleDateFormat sdf = new SimpleDateFormat("dd MM yyyy mm:ss") ;
			String date = "il est " + sdf.format(cal.getTime()) ;
			
			nombre = rand.nextInt(100);
			PrintWriter out = new PrintWriter(fw);
			out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
			out.println("<html>");
			out.println("<head>");
			out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
			out.println("<meta http-equiv=\"refresh\" content=\"1\">");
			out.println("<title>Essai refresh</title>");
			out.println("</head>");
			out.println("<body>");
			out.println(nombre);
			out.println("</br>") ;
			if (nombre < 50) {
				out.println("ok");
			} else
				out.println("ko");
			out.println("</br>") ;
			out.println(date) ;
			out.println("</body>");
			out.println("</html>");

			out.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

			try {
				sleep(500);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
